package com.vcc.data.mapper;

import com.mybatisflex.core.BaseMapper;
import com.vcc.data.entity.WalletDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

@Mapper
public interface WalletDetailMapper extends BaseMapper<WalletDetail> {


    @Select("SELECT SUM(amount) " +
            "FROM vcc_wallet_detail " +
            "WHERE user_id = #{userId} " +
            "AND use_flag = #{useFlag}")
    BigDecimal sumAmountByUserId(
            @Param("userId") Long userId,
            @Param("useFlag") Integer useFlag
    );

}
